package thread;

/**
 * sleep方法要求必须处理中断异常。
 * 当一个线程调用
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread(){
            @Override
            public void run() {
                System.out.println("林：刚美容完！睡一会");
                try {
                    Thread.sleep(50000);
                } catch (InterruptedException e) {
                    System.out.println("林：干嘛呢！干嘛呢！干嘛呢！干嘛呢！都破相了！");
                }
                System.out.println("林：醒了");
            }
        };
        lin.start();


        Thread huang = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<10;i++){
                    System.out.println("黄：八十！");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("咣当！");
                System.out.println("黄：大哥，搞定！");
                lin.interrupt();//中断lin线程的睡眠阻塞
            }
        };
        huang.start();
    }
}
